package com._CPA_.dao;

import com._CPA_.pojo.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.common.Mapper;
import java.time.LocalDate;
import java.util.List;

@RestController
public interface RootMapper extends Mapper<UserInfo> {

    //  查询用户名是否相同
    @Select("select user_name from user_info where user_name = #{name}")
    public String selectUserName(String name);

    // 查询手机号是否相同
    @Select("select phone from user_info where phone = #{My_phone}")
    public String selectPhone(String My_phone);

    //获取当前页的结果列表
    List<UserInfo> listSelect( String username,  String gender,  Short vip,Short ifAdmin, LocalDate begin, LocalDate end);
    /**
     * 批量删除
     * @param userIds
     */
    void myDelete(@Param("userIds") List<String> userIds);



    //  管理员修改功能  根据对象来进行修改每个信息
    @Update("update cpa_db.user_info set user_name = #{userName},gender = #{gender},phone = #{phone},nick_name = #{nickName},if_vip = #{ifVip},if_admin=#{ifAdmin},user_icon=#{userIcon} where user_id = #{userId}")
    public void isUpdate(UserInfo userInfo);

    // 登录校验
    @Select("select * from cpa_db.user_info where user_name = #{userName} and password = #{password} and if_admin = 1")
    public UserInfo login(UserInfo userInfo);

}
